"use strict";

/**
 * @ngdoc function
 * @name jgappApp.controller:RelativepageCtrl
 * @description
 * # RelativepageCtrl
 * Controller of the jgappApp
 */
angular
  .module("jgappApp")
  .controller(
    "RelativepageCtrl",
    function ($scope, $timeout, Util, $rootScope, $routeParams, FileService, TaskReviewService, openApi) {
      $scope.formKey = $routeParams.formKey;
      var param = {};
      param.formKey = $routeParams.formKey;
      param.moduleNo = $routeParams.moduleNo;
      // 获取回显的详细信息
      var getDetailData = function () {
        var options = {};
        options.param = param;
        options.url = openApi.getRelatedModuleData;
        options.callback = function (data) {
          $scope.process_id = data.processInstanceId;
        };
        var TaskReview = new TaskReviewService(options);
        $scope.TaskReview = TaskReview;
      };
      $scope.hrefLink = function (href) {
        // ios & android are opened in the different way
        OpenFile.showfile(href)
      };
      $scope.goDetail = function (fileData) {
        if (Util.isImg(fileData)) {
          FileService.showfile(fileData);
        } else if (Util.isFile(fileData)) {
          OpenFile.open(fileData);
        } else {
          Util.Toast("移动端不支持预览");
        }
      };
      var init = function () {
        $timeout(
          function () {
            Util.insertRelList({
              scope: $scope
            });
          },
          500
        );
        getDetailData();
        $rootScope.nofooter = true
      };
      // 初始化
      init();
    }
  );
